package com.itfreer.cms.service.content;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.cms.dao.content.ColumnDao;
import com.itfreer.cms.entity.content.ColumnEntity;
import com.itfreer.cms.service.content.ColumnService;
import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.imp.DictionaryServiceImp;
import com.itfreer.form.dictionary.base.DictionaryItem;

/**
 * 栏目管理实现类
 */
@Component("columnManagelmp")
public class ColumnServicelmp extends DictionaryServiceImp<ColumnEntity> implements ColumnService {
	
	@Autowired
	private ColumnDao columnDao;

	@Override
	protected BaseDao<ColumnEntity> getDao() {
		return columnDao;
	}

	@Override
	public String getDictionaryName() {
		return "cms_column";
	}

	@Override
	protected DictionaryItem convert(ColumnEntity entity) {
		DictionaryItem toEntity = new DictionaryItem();
		BeanUtils.copyProperties(entity, toEntity);
		toEntity.getOther().put("siteId", entity.getSiteId());
		toEntity.getOther().put("createDate", entity.getCreateDate());
		toEntity.getOther().put("recommend", entity.getRecommend());
		toEntity.getOther().put("image", entity.getImage());
		toEntity.getOther().put("mode", entity.getMode());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "id,pid,display,code,valid,leaf,siteId,createDate,recommend,image,mode";
	}
}
